<!--  -->
<template>
  <div class="Articlefl maincon">
    <!-- 订单信息 -->
    <div class="topsearch">
      <el-row :gutter="15">
        <el-col :md="24" :lg="6" :xl="6" class="reals">
          <el-card shadow="hover">
            <div class="realstop">
              <div class="r-t-left">
                <div class="leftcon">
                  <i
                    class="
                      iconfont
                      icon-dingdandingdanmingxishouzhimingxi
                      iconstyle
                    "
                  ></i>
                </div>
              </div>
              <div class="r-t-right">
                <span>用户总数</span>
                <span>84</span>
              </div>
            </div>
          </el-card>
        </el-col>
        <el-col :md="24" :lg="6" :xl="6" class="reals">
          <el-card shadow="hover">
            <div class="realstop">
              <div class="r-t-left">
                <div class="leftcon">
                  <i class="iconfont icon-yonghu iconstyle"></i>
                </div>
              </div>
              <div class="r-t-right">
                <span>今日活跃人数</span>
                <span>84</span>
              </div>
            </div>
          </el-card>
        </el-col>
        <el-col :md="24" :lg="6" :xl="6" class="reals">
          <el-card shadow="hover">
            <div class="realstop">
              <div class="r-t-left">
                <div class="leftcon">
                  <i class="iconfont icon-huiyuan iconstyle"></i>
                </div>
              </div>
              <div class="r-t-right">
                <span>今日购买人数</span>
                <span>84</span>
              </div>
            </div>
          </el-card>
        </el-col>

        <el-col :md="24" :lg="6" :xl="6" class="reals">
          <el-card shadow="hover">
            <div class="realstop">
              <div class="r-t-left">
                <div class="leftcon">
                  <i class="iconfont icon-duosucai iconstyle"></i>
                </div>
              </div>
              <div class="r-t-right">
                <span>今日投稿人数</span>
                <span>84</span>
              </div>
            </div>
          </el-card>
        </el-col>
      </el-row>
    </div>

    <!-- table -->
    <el-card shadow="hover" class="treetable">
      <el-form ref="formInline" inline :model="formInline" label-width="120px">
        <el-form-item label="搜索：">
          <el-select
            size="small"
            style="width: 100px"
            v-model="formInline.status"
            placeholder="请选择"
            clearable
          >
            <el-option
              v-for="(item, index) in furlist"
              :key="index"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>
          <el-input
            style="width: 200px"
            size="small"
            v-model="formInline.name"
            placeholder="输入分类名称"
            clearable
          ></el-input>
        </el-form-item>

        <el-form-item label="注册时间：">
          <el-date-picker
            v-model="formInline.values"
            size="small"
            type="daterange"
            range-separator="-"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            value-format="yyyy-MM-dd"
            @change="timechange"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="会员类型：">
          <el-checkbox-group v-model="formInline.checkboxorder" size="small">
            <el-checkbox-button
              v-for="city in orderstate"
              :label="city"
              :key="city"
              >{{ city }}</el-checkbox-button
            >
          </el-checkbox-group>
        </el-form-item>

        <el-form-item label="所属区域：" style="width: 30%; margin-right: 50px">
          <el-select
            size="small"
            v-model="formInline.status"
            placeholder="请选择"
            clearable
          >
            <el-option
              v-for="(item, index) in furlist"
              :key="index"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button
            size="small"
            type="primary"
            icon="el-icon-search"
            @click="search"
            >搜索</el-button
          >
          <el-button size="small" icon="el-icon-refresh" @click="resetForm"
            >重置</el-button
          >
        </el-form-item>
      </el-form>
      <el-table
        v-loading="loading"
        element-loading-text="耗尽脑汁加载中"
        :data="tableData"
        style="width: 100%"
        :header-cell-style="{ textAlign: 'center' }"
        :cell-style="{ textAlign: 'center' }"
      >
        <el-table-column type="expand" width="20px">
          <template slot-scope="props">
            <el-form label-position="left" inline class="demo-table-expand">
              <el-form-item label="商品名称">
                <span>{{ props.row.name }}</span>
              </el-form-item>
              <el-form-item label="所属店铺">
                <span>{{ props.row.shop }}</span>
              </el-form-item>
              <el-form-item label="商品 ID">
                <span>{{ props.row.id }}</span>
              </el-form-item>
              <el-form-item label="店铺 ID">
                <span>{{ props.row.shopId }}</span>
              </el-form-item>
              <el-form-item label="商品分类">
                <span>{{ props.row.category }}</span>
              </el-form-item>
              <el-form-item label="店铺地址">
                <span>{{ props.row.address }}</span>
              </el-form-item>
              <el-form-item label="商品描述">
                <span>{{ props.row.desc }}</span>
              </el-form-item>
            </el-form>
          </template>
        </el-table-column>
        <el-table-column label="会员ID" prop="id" width="100px">
        </el-table-column>
        <el-table-column label="会员头像">
          <template slot-scope="scope">
            <viewer>
              <img
                :src="scope.row.tx"
                alt=""
                style="cursor: pointer"
                width="80"
                height="45"
            /></viewer>
          </template>
        </el-table-column>
        <el-table-column label="用户昵称" prop="name"> </el-table-column>
        <el-table-column label="用户等级" prop="vip"> </el-table-column>
        <el-table-column label="注册时间" prop="zcdate"> </el-table-column>
        <el-table-column label="用户状态">
          <template slot-scope="scope">
            <el-tag :type="scope.row.zt | statusFilter">
              {{ scope.row.zt }}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column label="订单状态num" prop="orderzt">
          <template slot-scope="scope">
            <el-tag :type="scope.row.orderzt | statusFilternum">
              {{ ddztobj[scope.row.orderzt] }}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column fixed="right" label="操作">
          <template slot-scope="scope">
            <el-button
              @click="handleEdit(scope.$index, scope.row)"
              type="text"
              size="small"
              icon="el-icon-edit"
            >
              详情
            </el-button>
            <el-button
              @click.native.prevent="djRow(scope.$index, tableData)"
              type="text"
              size="small"
              icon="el-icon-turn-off"
              style="color: red"
            >
              冻结
            </el-button>
          </template>
        </el-table-column>
      </el-table>
      <div class="pagecount">
        <Pagination v-bind:child-msg="pageparm" @callFather="callFather" />
      </div>
    </el-card>
    <!-- 编辑/增加 -->
    <el-dialog :visible.sync="editFormVisible" width="30%" @click="closeDialog">
      <el-descriptions title="详情" direction="vertical" :column="4" border>
        <el-descriptions-item label="id">{{
          shopitem.id
        }}</el-descriptions-item>
        <el-descriptions-item label="订单类型">{{
          shopitem.type
        }}</el-descriptions-item>
        <el-descriptions-item label="下单时间" :span="2">{{
          shopitem.orderdate
        }}</el-descriptions-item>
        <el-descriptions-item label="支付时间"
          >{{ shopitem.paydate }}
        </el-descriptions-item>
        <el-descriptions-item label="订单状态">
          <el-tag :type="shopitem.orderzt | statusFilternum">{{
            shopitem.orderzt
          }}</el-tag>
        </el-descriptions-item>
        <el-descriptions-item label="购买信息">
          <img :src="shopitem.payimg" alt="" width="150" height="100" />
        </el-descriptions-item>
      </el-descriptions>

      <div slot="footer" class="dialog-footer">
        <el-button
          size="small"
          type="primary"
          :loading="loading"
          class="title"
          @click="closeDialog"
          >关闭</el-button
        >
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { viplist } from "./mock";
export default {
  data() {
    return {
      loading: false, //是显示加载
      // 搜索参数
      formInline: {
        name: "",
        page: 1,
        size: 10,
        checkboxorder: ["全部"],
        checkboxpay: ["全部"],
        values: "",
        login_time_begin: "",
        login_time_end: "",
        status: "2",
      },
      orderstate: ["全部", "付费", "未付费"],
      ddztobj: {
        1: "已下单",
        2: "已支付",
        3: "已完成",
        4: "已退款",
      },
      paymode: ["全部", "微信", "支付宝", "余额", "积分", "其他"],
      tableData: [],
      // 分页参数
      pageparm: {
        currentPage: 1,
        pageSize: 10,
        total: 10,
      },
      // 编辑界面
      title: "添加",
      editFormVisible: false, //控制编辑页面显示与隐藏
      editForm: {
        //编辑页的数据
        name: "",
        inouttype: "",
        spell: "",
        comment: "",
        id: "",
      },
      rules: {
        name: [{ required: true, message: "请输入分类名称", trigger: "blur" }],
        spell: [{ required: true, message: "请输入所属分类", trigger: "blur" }],
      },
      furlist: [
        { label: "全部", value: "2" },
        { label: "杨旺", value: "1" },
        { label: "张", value: "0" },
      ],
      shopitem: {},
    };
  },
  filters: {
    statusFilter(status) {
      const statusMap = {
        正常: "success",
        冻结: "info",
      };
      return statusMap[status];
    },
    statusFilternum(status) {
      const statusMap = {
        1: "",
        2: "warning",
        3: "success",
        4: "info",
      };
      return statusMap[status];
    },
  },
  methods: {
    // 获取列表
    getlist() {
      this.loading = true;
      this.tableData = viplist;
      // this.pageparm.currentPage = this.formInline.page;
      // this.pageparm.pageSize = this.formInline.size;
      // this.pageparm.total = tabData.count;
      this.loading = false;
    },
    // 选择时间事件
    timechange(e) {
      this.formInline.login_time_begin = e[0];
      this.formInline.login_time_end = e[1];
    },
    // 搜索
    search() {},
    // 重置
    resetForm() {},
    // 分页插件事件
    callFather(parm) {
      this.formInline.page = parm.currentPage;
      this.formInline.size = parm.pageSize;
      console.log(parm);
    },
    //显示详情界面
    handleEdit: function (index, row) {
      console.log(row);
      this.editFormVisible = true;
      this.shopitem = row;
    },
    // 冻结
    djRow(index, row) {
      console.log(index);
      console.log(row);
      this.$confirm("确定要冻结吗?", "信息", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.$message({
            type: "success",
            message: "完成!",
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消",
          });
        });
    },
    // 关闭编辑、增加弹出框
    closeDialog() {
      this.editFormVisible = false;
    },
  },
  created() {
    console.log(viplist);
    this.getlist();
  },
};
</script>
<style lang='scss' scoped>
.demo-table-expand {
  font-size: 0;
}
.demo-table-expand label {
  width: 90px;
  color: #99a9bf;
}
.demo-table-expand .el-form-item {
  margin-right: 0;
  margin-bottom: 0;
  width: 50%;
}

.Articlefl {
  .topsearch {
    height: 10%;
    .reals {
      padding: 10px 0;
      &:nth-child(2) {
        .realstop {
          .r-t-left {
            .leftcon {
              background-color: #fdc103;
            }
          }
        }
      }
      &:nth-child(3) {
        .realstop {
          .r-t-left {
            .leftcon {
              background-color: #36b206;
            }
          }
        }
      }
      &:nth-child(4) {
        .realstop {
          .r-t-left {
            .leftcon {
              background-color: #ec119a;
            }
          }
        }
      }
      .realstop {
        display: flex;
        align-items: center;
        .r-t-left {
          flex: 5;
          display: flex;
          justify-content: center;
          .leftcon {
            display: inline-block;
            background-color: #03b4fd;
            width: 60px;
            height: 60px;
            border-radius: 50%;
            line-height: 60px;
            text-align: center;
            .iconstyle {
              color: #ffffff;
              font-size: 20px;
            }
          }
        }
        .r-t-right {
          flex: 5;
          display: flex;
          flex-direction: column;
          span {
            color: #333;

            &:first-child {
              font-size: 14px;
              margin-bottom: 10px;
            }
            &:last-child {
              font-size: 18px;
            }
          }
        }
      }
    }
  }
  .treetable {
    margin-top: 20px;
    height: calc(88% - 20px);
    overflow-y: auto;
    // padding-bottom: 50px;
    .pagecount {
      // width: 100%;
      // position: absolute;
      // bottom: 10px;
      // margin-top: 30px;
      // bottom: 16px;
      // background: #fff;
      // z-index: 6;
      // .page-box {
      //   margin: 10px auto;
      //   position: absolute;
      //   bottom: 10px;
      //   right: 72px;
      // }
    }
  }
}
</style>